//
//  FeedBackViewController.m
//  MoXiProject
//
//  Created by 周筱雯 on 2017/7/3.
//  Copyright © 2017年 周筱雯. All rights reserved.
//

#import "FeedBackViewController.h"

@interface FeedBackViewController ()
<
    UITextViewDelegate
>
{
    
    UILabel * label;
}
@property (weak, nonatomic) IBOutlet UITextView *textView;
@property (weak, nonatomic) IBOutlet UITextField *phonetext;
@property (weak, nonatomic) IBOutlet UIButton *feedClick;
@end

@implementation FeedBackViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.
    [self.navigationItem setTitle:@"意见反馈"];
    [self.view setBackgroundColor:DEF_COLOR_F0F0F0];
    
    
    label = [[UILabel alloc] initWithFrame:CGRectMake(3, 8, DEF_DEVICE_WIDTH - 30, 25)];
    label.enabled = NO;
    [label setText:@"请输入你的反馈意见"];
    [label setFont:[UIFont systemFontOfSize:15.f]];
    [label setTextColor:[UIColor lightGrayColor]];
    [self.textView addSubview:label];
    
    [[self.feedClick rac_signalForControlEvents:UIControlEventTouchUpInside] subscribeNext:^(id x) {
        
        if ([self feedIfelse]) {
            
            [self.navigationController popViewControllerAnimated:YES];
            [MXUtility showTips:@"反馈成功，感谢你的反馈～"];
        }
    }];
}

-(BOOL) feedIfelse{

    if ([MXUtility NSNULLString:self.textView.text]) {
        [MXUtility showTips:@"小主，请留下你的宝贵建议哦～"];
        return false;
    }
    
    return true;
}

-(void)textViewDidChange:(UITextView *)ttextView{
    if (ttextView.text.length == 0) {
        [label setHidden:NO];
    }else{
        [label setHidden:YES];
    }
}


-(void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event{
    [self.textView resignFirstResponder];
    [self.phonetext resignFirstResponder];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
